import os

def run(task='', data_dir='', cfg_id='', github_dir='', weights='', out_dir='', device='', logger=None,
    main_queue=None, sub_queue=None, split='1::', epochs=0, batch_size=0, workers='8', im_sz='', **kwargs):

    if 'yolov5' in cfg_id:

        print("run")
        cfg_id = cfg_id.replace('yolov5_', '')
        path1 = os.path.dirname(__file__)
        print(path1)

        import project.yolov5 as yolov5

        try:
            yolov5.train.run(
                task=task, data_dir=data_dir, cfg_id=cfg_id, github_dir=github_dir, device=device, weights=weights,
                out_dir=out_dir, logger=logger,
                main_queue=main_queue, sub_queue=sub_queue, split=split, epochs=epochs, batch_size=batch_size,
                workers=workers, im_sz=im_sz, **kwargs)

        except Exception as e:
            print(str(e))
            if logger:
                logger.log(logger.ERROR, e, exception=True)
            if sub_queue:
                sub_queue.put({'err': str(e)})

    if 'timm' in cfg_id:
        import project.timm as timm

        cfg_id = cfg_id.replace('timm-', '')

        timm.train.run(
            task=task, data_dir=data_dir, cfg_id=cfg_id, github_dir=github_dir, device=device, weights=weights, out_dir=out_dir, 
            main_queue=main_queue, sub_queue=sub_queue, split=split, epochs=epochs, batch_size=batch_size, workers=workers, im_sz=im_sz)